package com.abc.cloud.config;

import com.abc.cloud.service.ChatDetailService;
import com.abc.cloud.service.ChatDetailUserService;
import com.abc.cloud.service.ChatService;
import com.abc.cloud.service.ChatUserService;
import com.abc.cloud.websocket.ChatWebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
public class WebSocketConfig {
    /**
     * 	注入ServerEndpointExporter，
     * 	这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
     */
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    /**
     * 注入service
     * @param chatUserService
     */
    @Autowired
    private void setChatService(ChatUserService chatUserService,
                                ChatService chatService,
                                ChatDetailService chatDetailService,
                                ChatDetailUserService chatDetailUserService){
        ChatWebSocket.chatUserService = chatUserService;
        ChatWebSocket.chatService = chatService;
        ChatWebSocket.chatDetailService= chatDetailService;
        ChatWebSocket.chatDetailUserService = chatDetailUserService;
    }


}
